package javaTest05.exercise02.client;

import javaTest05.utils.LogUtils;

import java.net.InetSocketAddress;
import java.net.Socket;


public class Client {

    public static void main(String[] args) {
        try {
            Socket client = new Socket();//创建套接字

            client.connect(new InetSocketAddress("localhost",1314));//连接到远程服务器

            LogUtils.info("与服务端已建立链接:"+client.getRemoteSocketAddress()+",当前地址为:"+client.getLocalSocketAddress());

            Thread receiveHandler = new Thread(new ClientReceiveHandler(client));//收信线程启动

            Thread sendHandler = new Thread(new ClientSendHandler(client));//发信线程启动

            sendHandler.start();

            receiveHandler.start();

        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
